#ifndef _DevicesSPI_H_
#define _DevicesSPI_H_


#ifndef SPI0
#define SPI0 0x01
#endif

#ifndef SPI1
#define SPI1 0x02
#endif


#define SPI0_NSS_SET_HIGH()                 GPIOA_SetBits(GPIO_Pin_12)
#define SPI0_NSS_SET_LOW()                  GPIOA_ResetBits(GPIO_Pin_12)


void vSPI0Init(void);
void vSPI1Init(void);

#define ucSPI0WriteReadByte(ucByte)         ucSPIWriteReadByte(SPI0, (ucByte))
#define ucSPI0WriteByte(ucByte)             vSPIWriteByte(SPI0, (ucByte))
#define ucSPI0ReadByte()                    ucSPIReadByte(SPI0)
#define cSPI0WriteDatas(pvDatas, iLength)   cSPIWriteDatas(SPI0, (pvDatas), (iLength))
#define cSPI0ReadDatas(pvDatas, iLength)    cSPIReadDatas(SPI0, (pvDatas), (iLength))

#define ucSPI1WriteReadByte(ucByte)         ucSPIWriteReadByte(SPI1, (ucByte))
#define ucSPI1WriteByte(ucByte)             vSPIWriteByte(SPI1, (ucByte))
#define ucSPI1ReadByte()                    ucSPIReadByte(SPI1)
#define cSPI1WriteDatas(pvDatas, iLength)   cSPIWriteDatas(SPI1, (pvDatas), (iLength))
#define cSPI1ReadDatas(pvDatas, iLength)    cSPIReadDatas(SPI1, (pvDatas), (iLength))

void vSPIWriteByte(uint32_t uiSpi, uint8_t ucByte);
uint8_t ucSPIReadByte(uint32_t uiSpi);
int8_t cSPIWriteDatas(uint32_t uiSpi, void *pvDatas, int32_t iLength);
int8_t cSPIReadDatas(uint32_t uiSpi, void *pvDatas, int32_t iLength);


#endif
